/* 
 * File:   main.cpp
 * Author: avvie
 *
 * Created on 06 August 2009, 11:25
 */

#include <stdlib.h>
#include "display.h"

//GL Display Function
void display(){
    // Clear colour and depth buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    // Replace current matrix with identity matrix
    glLoadIdentity();

    gluLookAt(0.0,0.0,0.0,
              0.0,0.0,0.0,
              0.0,1.0,0.0);

    glPushMatrix();
   // glTranslatef(-0.0,-50.0,-50.0);
    renderCube();
    glPopMatrix();

    glFlush();
    glutSwapBuffers();
    return;
}

//      RESHAPE FUNCTION
void reshape(int w, int h){

  glViewport(0, 0, w, h);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();

  gluPerspective(120.0, ((GLfloat) w)/((GLfloat)h), 1.0, 1000.0);

  glMatrixMode(GL_MODELVIEW);
  glutPostRedisplay();
  return;

}

//GL Initialization Function
void Init(int argc, char** argv){

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
    glutInitWindowSize(1024,768);
    glutCreateWindow("Trisssss");
    glEnable(GL_DEPTH_TEST);
    glShadeModel(GL_SMOOTH);
    glMatrixMode(GL_MODELVIEW);
    glClearColor(1.0, 1.0, 1.0, 0.0);

}

int main(int argc, char** argv) {

    Init(argc, argv);
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    //Tetris Pieces
    initTris();

    glutMainLoop();
    
    return (EXIT_SUCCESS);
}

